package a.j;

import a.c.ab;
import a.c.d;
import a.c.e;
import a.d.k;
import a.d.o;
import a.d.w;
import a.j.a.j;

import java.awt.*;
import java.awt.geom.Line2D;
import java.lang.ref.WeakReference;

class gd
{
  private static final String a = "HierarchyManager.InterEdgeData.TARGET_PORT";
  private boolean b = true;
  private boolean d;
  static Class e;
  
  b_ a()
  {
    return new b_(null);
  }
  
  void a(pg parampg, double paramDouble1, double paramDouble2, qb paramqb)
  {
    w localw = new w(paramDouble1, paramDouble2);
    d locald = a(parampg, localw);
    ((b_)paramqb).a(parampg.a(), locald, localw);
  }
  
  protected void a(Graphics2D paramGraphics2D, tb paramtb, w paramw)
  {
    g localg = new g();
    localg.a(paramtb.h().m());
    if (!ld.E) {
      if (!paramtb.i().g()) {
        localg.a(paramtb.g().m());
      }
    }
    tb localtb = paramtb.e();
    localtb.a(new c_(localtb.k()));
    localtb.b(new c_(localtb.l()));
    localg.a(localg.p(), localg.r(), localtb);
    localtb.c(true);
    localtb.c(paramGraphics2D);
  }
  
  protected Rectangle a(tb paramtb, w paramw)
  {
    Rectangle2D.Double localDouble = new Rectangle2D.Double(0.0D, 0.0D, -1.0D, -1.0D);
    paramtb.a(localDouble);
    paramtb.h().b(localDouble);
    paramtb.g().b(localDouble);
    int i = (int)Math.floor(localDouble.getX());
    int j = (int)Math.floor(localDouble.getY());
    int k = (int)Math.ceil(localDouble.getX() + localDouble.getWidth());
    int m = (int)Math.ceil(localDouble.getY() + localDouble.getHeight());
    return new Rectangle(i, j, k - i, m - j);
  }
  
  public boolean b()
  {
    return this.b;
  }
  
  public void a(boolean paramBoolean)
  {
    this.b = paramBoolean;
  }
  
  protected d a(pg parampg, w paramw)
  {
    boolean bool3 = ld.E;
    double d1 = paramw.a();
    double d2 = paramw.b();
    d locald = a(parampg, d1, d2);
    g localg = parampg.a();
    if (((bool3) || (locald != null)) && (locald.c() == localg))
    {
      tb localtb = localg.t(locald);
      jd localjd1 = jd.b(localtb);
      if (!bool3) {}
      boolean bool1 = localjd1 == null ? localg.w(locald.e()).f(d1, d2) : localjd1.a(d1, d2);
      if (!bool1)
      {
        jd localjd2 = jd.d(localtb);
        if (!bool3) {}
        boolean bool2 = localjd2 == null ? localg.w(locald.f()).f(d1, d2) : localjd2.a(d1, d2);
        if (!bool2) {
          return locald;
        }
      }
    }
    return null;
  }
  
  private d a(pg parampg, double paramDouble1, double paramDouble2)
  {
    boolean bool = ld.E;
    sc localsc = b(parampg, paramDouble1, paramDouble2);
    if (!bool) {
      if (localsc.y()) {
        return localsc.o();
      }
    }
    Object localObject1;
    Object localObject2;
    tb localtb;
    if (!bool) {
      if (localsc.v())
      {
        localObject1 = localsc.q();
        localObject2 = ((ig)localObject1).lb();
        localtb = parampg.a().t((d)localObject2);
        if ((!bool) && ((!localtb.K()) || (!localtb.d(paramDouble1, paramDouble2)))) {
          break label225;
        }
        return localObject2;
      }
    }
    if (!bool) {
      if (localsc.z())
      {
        localObject1 = localsc.n();
        localObject2 = ((eb)localObject1).a();
        localtb = parampg.a().t((d)localObject2);
        if ((!bool) && ((!localtb.K()) || (!localtb.d(paramDouble1, paramDouble2)))) {
          break label225;
        }
        return localObject2;
      }
    }
    if ((bool) || (localsc.u()))
    {
      localObject1 = localsc.r();
      localObject2 = ((zd)localObject1).c();
      if ((bool) || ((((tb)localObject2).K()) && ((bool) || (((tb)localObject2).d(paramDouble1, paramDouble2))))) {
        return ((tb)localObject2).i();
      }
    }
    label225:
    return null;
  }
  
  protected void a(g paramg, d paramd, w paramw, e parame)
  {
    paramg.z();
    try
    {
      c(paramg, paramd, paramw, parame);
    }
    finally
    {
      paramg.A();
    }
  }
  
  private void c(g paramg, d paramd, w paramw, e parame)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    paramg.a(new ab(paramd).l());
    tb localtb1 = paramg.t(paramd);
    o[] arrayOfo = new o[localtb1.V()];
    int i = 0;
    do
    {
      while (!bool1)
      {
        if (i >= arrayOfo.length) {
          break;
        }
        arrayOfo[i] = localtb1.d(i).d();
        i++;
      }
    } while (bool2);
    tb localtb2 = localtb1.e();
    int j = b(localtb1, paramw);
    w localw1;
    if (j > -1)
    {
      localw1 = a(paramg, paramd, localtb1, j, paramw);
      a(paramg, paramd, parame, localtb2);
      k = paramd.f() == parame ? 1 : 0;
      localtb3 = k != 0 ? localtb1 : localtb2;
      localtb4 = k != 0 ? localtb2 : localtb1;
      if (!bool2)
      {
        if (j < 1)
        {
          localtb3.s();
          if ((!bool2) && (!bool1)) {
            break label337;
          }
        }
        if (bool2) {}
      }
      else if (j > localtb1.n() - 1)
      {
        localtb4.s();
        if ((!bool2) && (!bool1)) {
          break label337;
        }
      }
      int m = localtb3.n();
      do
      {
        do
        {
          if (m-- <= j) {
            break;
          }
          localtb3.a(localtb3.b(m));
          if (bool2) {
            break label289;
          }
          if (bool1) {
            break label282;
          }
        } while (!bool1);
      } while (bool2);
      m = j;
      label282:
      label289:
      do
      {
        if (m-- <= 0) {
          break;
        }
        localtb4.a(localtb4.b(m));
        if ((!bool2) && (bool1)) {
          break label350;
        }
      } while (!bool1);
    }
    else
    {
      localw1 = paramw;
      if (bool2) {
        break label350;
      }
      a(paramg, paramd, parame, localtb2);
    }
    label337:
    label350:
    int k = paramd.f() == parame ? 1 : 0;
    tb localtb3 = k != 0 ? localtb1 : localtb2;
    tb localtb4 = k != 0 ? localtb2 : localtb1;
    ld localld = paramg.w(parame);
    w localw2 = localld.f(localw1.a(), localw1.b()) ? localw1 : new w(localld.A(), localld.B());
    paramg.c(localtb4.i(), localw2);
    paramg.d(localtb3.i(), localw2);
    jd.a(null, localtb4);
    jd.b(null, localtb3);
    int n = arrayOfo.length;
    label599:
    do
    {
      ig localig1;
      do
      {
        if (n-- <= 0) {
          break label602;
        }
        localig1 = localtb1.d(n);
        ig localig2 = localtb2.d(n);
        if ((!bool2) && (bool1)) {
          return;
        }
        if (bool2) {
          break label599;
        }
        if (a(arrayOfo[n], localig1.d()) <= a(arrayOfo[n], localig2.d())) {
          break;
        }
        localig2.a(localig2.d(arrayOfo[n]));
        localtb1.c(n);
        if (bool2) {
          break label599;
        }
      } while (!bool1);
      localig1.a(localig1.d(arrayOfo[n]));
      localtb2.c(n);
    } while (!bool1);
    label602:
    a(paramg, paramd, parame);
    if (!bool2) {
      b(paramg, localtb2.i(), parame);
    }
  }
  
  private static void a(g paramg, d paramd, e parame, tb paramtb)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    j localj = paramg.K();
    Object localObject;
    if (((bool2) || (localj != null)) && (localj.e(paramd)))
    {
      if (!bool2)
      {
        if (paramd.f() == localj.c(paramd))
        {
          localObject = paramd.f();
          localj.a(paramd, localj.b(paramd), parame);
          if (bool2) {
            break label92;
          }
          paramg.a(parame, (e)localObject, paramtb);
          if (!bool1) {
            return;
          }
        }
        label92:
        if (bool2) {}
      }
      else if (paramd.e() == localj.b(paramd))
      {
        localObject = paramd.e();
        localj.a(paramd, parame, localj.c(paramd));
        paramg.a((e)localObject, parame, paramtb);
        if (bool2) {
          break label162;
        }
        if (!bool1) {
          return;
        }
      }
      localObject = localj.d(paramd).a("HierarchyManager.InterEdgeData.TARGET_PORT");
      label162:
      e locale1 = localj.c(paramd);
      e locale2 = paramd.f();
      localj.a(paramd, localj.b(paramd), parame);
      d locald = paramg.a(parame, locale2, paramtb);
      localj.b(locald, parame, locale1);
      if (!bool2)
      {
        if (localObject != null) {
          localj.d(paramd).b("HierarchyManager.InterEdgeData.TARGET_PORT");
        }
      }
      else
      {
        localj.d(locald).a("HierarchyManager.InterEdgeData.TARGET_PORT", localObject);
        if (!bool1) {}
      }
    }
    else
    {
      localObject = paramd.f();
      paramg.a(paramd, paramd.e(), parame);
      paramg.a(parame, (e)localObject, paramtb);
    }
  }
  
  private static double a(o paramo1, o paramo2)
  {
    w localw1 = paramo1.l();
    w localw2 = paramo2.l();
    double d1 = localw2.a() - localw1.a();
    double d2 = localw2.b() - localw1.b();
    return d1 * d1 + d2 * d2;
  }
  
  protected int b(tb paramtb, w paramw)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    double d1 = paramw.a();
    double d2 = paramw.b();
    double d3 = (1.0D / 0.0D);
    int i = -1;
    zd localzd = paramtb.k();
    ld localld = paramtb.h();
    double d4 = localzd.a(localld);
    double d5 = localzd.b(localld);
    int j = 0;
    Object localObject1 = paramtb.o();
    do
    {
      if (!((fb)localObject1).e()) {
        break;
      }
      localObject2 = ((fb)localObject1).a();
      d6 = ((eb)localObject2).b();
      d7 = ((eb)localObject2).c();
      d8 = Line2D.ptSegDistSq(d4, d5, d6, d7, d1, d2);
      if (!bool2)
      {
        if (d3 > d8)
        {
          d3 = d8;
          i = j;
        }
        d4 = d6;
        d5 = d7;
        ((fb)localObject1).f();
        j++;
      }
    } while (!bool1);
    localObject1 = paramtb.l();
    Object localObject2 = paramtb.g();
    double d6 = ((zd)localObject1).a((ld)localObject2);
    double d7 = ((zd)localObject1).b((ld)localObject2);
    double d8 = Line2D.ptSegDistSq(d4, d5, d6, d7, d1, d2);
    if (!bool2) {
      if (d3 > d8) {
        i = j;
      }
    }
    return i;
  }
  
  private static w a(g paramg, d paramd, tb paramtb, int paramInt, w paramw)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    double d1 = paramw.a();
    double d2 = paramw.b();
    if ((bool2) || ((!paramd.g()) && ((paramtb instanceof xb))))
    {
      Object localObject1 = paramg.r(paramd);
      int i = 0;
      Object localObject2 = paramtb.o();
      do
      {
        if (!((fb)localObject2).e()) {
          break;
        }
        eb localeb = ((fb)localObject2).a();
        if (bool1) {
          break label165;
        }
        w localw = new w(localeb.b(), localeb.c());
        if (!bool2)
        {
          if (paramInt == i) {
            return k.d(d1, d2, ((w)localObject1).a(), ((w)localObject1).b(), localw.a(), localw.b());
          }
          localObject1 = localw;
          ((fb)localObject2).f();
          i++;
        }
      } while (!bool1);
      label165:
      localObject2 = paramg.s(paramd);
      return k.d(d1, d2, ((w)localObject1).a(), ((w)localObject1).b(), ((w)localObject2).a(), ((w)localObject2).b());
    }
    return paramw;
  }
  
  protected void a(g paramg, d paramd, e parame)
  {
    c(paramg, paramd, parame);
  }
  
  protected void b(g paramg, d paramd, e parame)
  {
    c(paramg, paramd, parame);
  }
  
  private void c(g paramg, d paramd, e parame)
  {
    boolean bool = ld.E;
    if ((bool) || ((c()) && ((bool) || (d(paramg, paramd, parame))))) {
      e(paramg, paramd, parame);
    }
  }
  
  public boolean c()
  {
    return this.d;
  }
  
  public void b(boolean paramBoolean)
  {
    this.d = paramBoolean;
  }
  
  protected boolean d(g paramg, d paramd, e parame)
  {
    boolean bool = ld.E;
    tb localtb = paramg.t(paramd);
    if (!bool) {
      if ((localtb instanceof xb)) {
        return true;
      }
    }
    if (!bool) {
      if ((localtb instanceof wb))
      {
        if (!bool) {}
        Object localObject = wb.Z().a(((wb)localtb).ob(), e == null ? (gd.e = a("a.j.wb$o_")) : e);
        if (!bool) {
          if (!(localObject instanceof yd)) {
            if (bool) {
              break label109;
            }
          }
        }
        label109:
        return (localObject instanceof te);
      }
    }
    return false;
  }
  
  protected void e(g paramg, d paramd, e parame)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    tb localtb = paramg.t(paramd);
    ld localld = paramg.w(parame);
    fb localfb;
    eb localeb;
    if (paramd.e() == parame)
    {
      if ((bool2) || (jd.b(localtb) == null))
      {
        localfb = localtb.o();
        do
        {
          if ((!localfb.e()) || (localtb.n() <= localtb.r())) {
            break;
          }
          localeb = localfb.a();
          if (!bool2)
          {
            if (!localld.f(localeb.b(), localeb.c())) {
              break;
            }
            paramg.c(paramd, localeb.e());
          }
          if (!bool2)
          {
            if (localtb.a(localeb) == null) {
              break;
            }
            localfb.f();
          }
        } while (!bool1);
      }
    }
    else if ((bool2) || (jd.d(localtb) == null))
    {
      localfb = localtb.o();
      localfb.i();
      do
      {
        if ((!localfb.e()) || (localtb.n() <= localtb.r())) {
          break;
        }
        localeb = localfb.a();
        if (!bool2)
        {
          if (!localld.f(localeb.b(), localeb.c())) {
            break;
          }
          paramg.d(paramd, localeb.e());
        }
        if (!bool2)
        {
          if (localtb.a(localeb) == null) {
            break;
          }
          localfb.g();
        }
      } while (!bool1);
    }
  }
  
  private static sc b(pg parampg, double paramDouble1, double paramDouble2)
  {
    uc localuc = parampg.P();
    if (!ld.E) {
      if (localuc == null) {
        return new sc(parampg, paramDouble1, paramDouble2, true);
      }
    }
    return localuc.a(paramDouble1, paramDouble2, -1, true);
  }
  
  static Class a(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  
  private static final class c_
    extends zd
  {
    c_(zd paramzd)
    {
      super();
    }
    
    public void a(Graphics2D paramGraphics2D, ld paramld) {}
  }
  
  private final class b_
    implements qb
  {
    private WeakReference a;
    private WeakReference b;
    private w c;
    
    private b_() {}
    
    public void paint(Graphics2D paramGraphics2D)
    {
      a(paramGraphics2D, a(), b());
    }
    
    private void a(Graphics2D paramGraphics2D, g paramg, d paramd)
    {
      if ((paramg != null) && (paramd != null)) {
        gd.this.a(paramGraphics2D, paramg.t(paramd), this.c);
      }
    }
    
    public Rectangle getBounds()
    {
      return a(a(), b());
    }
    
    private Rectangle a(g paramg, d paramd)
    {
      if ((paramg != null) && (paramd != null)) {
        return gd.this.a(paramg.t(paramd), this.c);
      }
      return new Rectangle(0, 0, -1, -1);
    }
    
    void a(g paramg, d paramd, w paramw)
    {
      this.a = (paramg == null ? null : new WeakReference(paramg));
      this.b = (paramd == null ? null : new WeakReference(paramd));
      this.c = paramw;
    }
    
    private g a()
    {
      WeakReference localWeakReference = this.a;
      if (!ld.E) {}
      return localWeakReference == null ? null : (g)localWeakReference.get();
    }
    
    private d b()
    {
      WeakReference localWeakReference = this.b;
      if (!ld.E) {}
      return localWeakReference == null ? null : (d)localWeakReference.get();
    }
    
    b_(gd.0 param0)
    {
      this();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.gd

 * JD-Core Version:    0.7.0.1

 */